/**
 * Created by yhg97p on 2016/9/27.
 */
define(['app', 'filters/filters'], function(app) {
	app.register.controller('compReport', function($scope, $http, $state, $sce, $stateParams, $rootScope, $confirm) {
        $scope.loading_show = true;
		//企业成员列表      
		$scope.Actived=true;
		$scope.numb=0
		$http({
			url: app._baseUrl + '/QyManage/Report/userList',
			method: 'POST',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		}).success(function(res) {
			if(res.success) {
                $scope.loading_show = false;
				$scope.items = res.data;
				$scope.all = true;
                angular.forEach($scope.items, function(v,k) {
                	v.index=k})
			}
		});
		$http({
			url: app._baseUrl + '/QyManage/Report/allLearnData',
			method: 'POST',
			data: 'day_num=' + 1,
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		}).success(function(res) {
			if(res.success) {
                $scope.loading_show = false;
				$scope.all = true;
				$scope.learn = res.data.count_data;
				$scope.list = res.data.user_period_list;
				//console.log($scope.list)
				$scope.all = true;
				

			}
		});
		//单人报告页
		$scope.singlemember = function(index,item) {
			    $scope.temp = index;
			    $scope.num=0;
			    $scope.numb=0;
			    $scope.Actived=false;
				$scope.single_userid=item.user_id;
				$http({
					url: app._baseUrl + '/QyManage/Report/userLearnData',
					method: 'POST',
					data: {
						day_num: 1,
						user_id: item.user_id
					},
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}).success(function(res) {
					if(res.success) {
						$scope.all = false;
						$scope.single = true;
						$scope.singlelist = res.data;
						$scope.sin=$scope.singlelist.user_period_list;
						
					}
				});
				//单人昨天
				$scope.yester = function(single_userid) {
					$scope.numb=0

					$http({
						url: app._baseUrl + '/QyManage/Report/userLearnData',
						method: 'POST',
						data: {
							day_num: 1,
							user_id: item.user_id
						},
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded'
						}
					}).success(function(res) {
						if(res.success) {
							$scope.all = false;
							$scope.single = true;
							$scope.singlelist = res.data;
						}
					});
				}
				//单人七天
				$scope.seven = function(single_userid) {
				    $scope.numb=1
					$http({
						url: app._baseUrl + '/QyManage/Report/userLearnData',
						method: 'POST',
						data: {
							day_num: 7,
							user_id: item.user_id
						},
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded'
						}
					}).success(function(res) {
						if(res.success) {
							$scope.all = false;
							$scope.single = true;
							$scope.singlelist = res.data;

						}
					});
				}
				

			
		}
		//所有成员
		$scope.allin = function() {
			$scope.Actived=true;
			$scope.num=1;
			$scope.numb=0;
			$http({
				url: app._baseUrl + '/QyManage/Report/allLearnData',
				method: 'POST',
				data: 'day_num=' + 1,
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
			}).success(function(res) {
				if(res.success) {
					$scope.all = true;
					$scope.member_blank=false;
					$scope.learn = res.data.count_data;
					$scope.list = res.data.user_period_list;
					$scope.single= false;
				}
			});
		}
		//所有七天
		$scope.seveall = function() {
		    $scope.numb=1
			$http({
				url: app._baseUrl + '/QyManage/Report/allLearnData',
				method: 'POST',
				data: 'day_num=' + 7,
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
			}).success(function(res) {
				if(res.success) {
					$scope.all = true;
					$scope.learn = res.data.count_data;
					$scope.list = res.data.user_period_list;
					$scope.all = true;

				}
			});
		}
		
		//所有昨天
		$scope.yesterall = function() {
		    $scope.numb=0
			$http({
				url: app._baseUrl + '/QyManage/Report/allLearnData',
				method: 'POST',
				data: 'day_num=' + 1,
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
			}).success(function(res) {
				if(res.success) {
					$scope.all = true;
					$scope.learn = res.data.count_data;
					$scope.list = res.data.user_period_list;
					$scope.all = true;

				}
			});
		}

	})
})